// Generate PNG-Icons from SVG via Canvas (works in browser) // Outputs: 120x120, 152x152, 167x167, 180x180 (Apple Touch Icons) // Plus: 192x192, 512x512 (PWA standard) // Plus: 1024x1024 (App Store) const SIZES = [120, 152, 167, 180, 192, 512, 1024]; // Inline SVG (purple gradient circle with chat bubble) const SVG = ` `; async function generate() { const svgBlob = new Blob([SVG], { type: 'image/svg+xml' }); const svgUrl = URL.createObjectURL(svgBlob); const img = new Image(); await new Promise((resolve, reject) => { img.onload = resolve; img.onerror = reject; img.src = svgUrl; }); const out = {}; for (const size of SIZES) { const canvas = document.createElement('canvas'); canvas.width = size; canvas.height = size; const ctx = canvas.getContext('2d'); ctx.drawImage(img, 0, 0, size, size); const blob = await new Promise((resolve) => canvas.toBlob(resolve, 'image/png')); out[`png-${size}`] = await blobToBase64(blob); } return out; } function blobToBase64(blob) { return new Promise((resolve) => { const reader = new FileReader(); reader.onload = () => resolve(reader.result); reader.readAsDataURL(blob); }); } generate().then((out) => { // Output to console as JSON const compact = {}; for (const k of Object.keys(out)) { compact[k] = out[k].substring(0, 100) + '... (' + out[k].length + ' chars)'; } console.log(JSON.stringify(compact)); // Store in window for retrieval window.__generatedIcons = out; });